﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace XTeam.Core.Interface
{
    public interface IDBCore<T> where T : class,new()
    {

        /// <summary>
        /// 查找
        /// </summary>
        T Find(Func<T, bool> filter);
        /// <summary>
        /// 批量更新
        /// </summary>
        int Update(IList<T> entities, Func<T, object> fileds = null, bool withOut = false);

        /// <summary>
        /// 批量删除
        /// </summary>
        int Delete(IList<T> entities);

        /// <summary>
        /// 批量增加
        /// </summary>
        int Append(IList<T> entities);
    }

    public interface IDbCore
    {

        IQueryable<T> AsQueryable<T>() where T : class,new();
        /// <summary>
        /// 查找
        /// </summary>
        T Find<T>(Func<T, bool> filter) where T : class,new();

        /// <summary>
        /// 搜索
        /// </summary>
        IEnumerable<T> Search<T>(Func<T, bool> filter) where T : class,new();
        /// <summary>
        /// 查找并分页
        /// </summary>
        IEnumerable<T> Search<T>(Func<T, bool> filter, int pageIndex, int pageSize, out int totalRows) where T : class,new();

        /// <summary>
        /// 批量更新
        /// </summary>
        int Update<T>(IList<T> entities, Func<T, object> fileds = null, bool withOut = false) where T : class,new();

        /// <summary>
        /// 批量删除
        /// </summary>
        int Delete<T>(IList<T> entities) where T : class,new();

        /// <summary>
        /// 批量增加
        /// </summary>
        int Append<T>(IList<T> entities) where T : class,new();

    }
}
